<template>
  <div>
    <m-head title="名家讲师"></m-head>
    <div class="list">
      <pull-to @infinite-scroll="getList()" class="file-lists">
      <div class="item" v-for="(item, index) in list" :key="index" @click="$router.push({path:'/teacherdetail',query:{id:item.id}})">
        <img :src="item.img" alt="">
        <div class="info">
          <h3>{{item.name}}</h3>
          <p v-html="item.des"></p>
        </div>
      </div>
      </pull-to>
    </div>
  </div>
</template>

<script>
import pullTo from 'vue-pull-to'
import MHead from './MHeader'
import * as info from '../api/info'
export default {
  name: 'teacher',
  data: function () {
    return {
      list: [
        // {
        //   tid: 0,
        //   name: '张雪峰',
        //   img: '../../static/images/teacher.jpg',
        //   intro: '著名外教培训指导老师，育儿英语专家，专业英语8级，BEC商务高级证实'
        // },
        // {
        //   tid: 1,
        //   name: '张雪峰',
        //   img: '../../static/images/teacher.jpg',
        //   intro: '著名外教培训指导老师，育儿英语专家，专业英语8级，BEC商务高级证实'
        // },
        // {
        //   tid: 2,
        //   name: '张雪峰',
        //   img: '../../static/images/teacher.jpg',
        //   intro: '著名外教培训指导老师，育儿英语专家，专业英语8级，BEC商务高级证实'
        // },
        // {
        //   tid: 3,
        //   name: '张雪峰',
        //   img: '../../static/images/teacher.jpg',
        //   intro: '著名外教培训指导老师，育儿英语专家，专业英语8级，BEC商务高级证实'
        // },
        // {
        //   tid: 4,
        //   name: '吴丽丽',
        //   img: '../../static/images/teacher.jpg',
        //   intro: '著名外教培训指导老师，育儿英语专家，专业英语8级，BEC商务高级证实'
        // }
      ],
      page: 1
    }
  },
  components: {
    'm-head': MHead,
    pullTo
  },
  mounted () {
    this.getList()
  },
  methods: {
    getList () {
      info.getTeachers(this.page, 20).then(res => {
        console.log(res)
        this.list = this.list.concat(res.data)
        console.log(this.list)
        this.page++
      })
    }
  }
}
</script>

<style scoped>
.list{
  padding: .3rem;
}
.item{
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid #eee;
  padding: .3rem 0;
}
.item img{
  width: 2.8rem;
  margin-right: .3rem;
}
.item .info{
  flex-grow: 1;
  padding-top: .16rem;
}
.item .info h3{
  font-size: .42rem;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #000;
}
.item .info p{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: .46rem;
  margin-top: .2rem;
  font-size: .34rem;
}
</style>
